package com.itheima.demo02;

import java.util.ArrayList;
import java.util.List;

//Stream流
public class StreamClass03 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>(List.of("张三丰","李白","张强","白居易","张铁林","张无忌"));

        ArrayList<String> list2 = new ArrayList<>();
        for (String s : list1) {
            if (s.startsWith("张")){
                list2.add(s);
            }
        }
        System.out.println(list2);
        System.out.println("-------------------------------");

        list1.stream().filter(name -> name.startsWith("张"))
                .filter(name -> name.length() == 3)
                .forEach(s -> System.out.println(s));
    }
}
